﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05_EqualSidesOfAnArray
{
    public class Kata
    {
        public static int FindEvenIndex(int[] arr)
        {
            //Code goes here!
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr.Take(i).ToArray().Sum() == arr.Skip(i+1).ToArray().Sum())
                    return i;
            }
            return -1;

            //使用Linq查询实现
            //return Enumerable.Range(0, arr.Length).ToList().FindIndex(i => arr[..i].Sum() == arr[(i + 1)..].Sum());
        }
    }
}
